package com.kuang;

public class test {

    public static void main(String[] args) {
        //String acctCodeTemp = " 0001509475000 "; // 0001509475
        //String acctCode = acctCodeTemp.replaceFirst("^0*", "");  // 0001509475

        String str = " hi world ~ ";
        //方法1：str.trim()
        System.out.println("1--->"+str.trim());

        //方法2：str.repalce(" ","")
        System.out.println("2--->"+str.replace(" ", ""));
        System.out.println(str);
        //方法3：str.repalceAll(" ","")
        System.out.println("3--->"+str.replaceAll(" ", ""));
        System.out.println(str);
        //方法4：str.repalceAll(" +","")
        System.out.println("4--->"+str.replaceAll(" +", ""));
        System.out.println(str);
        //方法5：str.repalceAll("\\s*","")
        System.out.println("4--->"+str.replaceAll("\\s*", ""));
        System.out.println(str);
    }
}
